package com.tanger.es;

import lombok.Builder;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.*;

import java.util.List;

/**
 * @Description TODO
 * @Author Hchenbin
 * @Date 2023-12-08 16:20
 * @Version 1.0
 */
@Data
@Builder
@Document(indexName="_tanger_goods")
@Setting(settingPath = "elastic-analyzer.json")
public class EsGoods {
    @Id
    private String id;
    @Field(type = FieldType.Keyword, store = true)//store = true 对该字段单独存储倒排索引
    private String name;
    @MultiField(mainField = @Field(type = FieldType.Text, analyzer = "analyzer_ngram", searchAnalyzer = "analyzer_ngram_search"),
            otherFields = @InnerField(suffix = "keyword", type = FieldType.Keyword))
    private String pinyinInitials;
    @Field(type = FieldType.Keyword, store = true)
    private String firstLetter;
    @Field(type = FieldType.Double)
    private Double price;
    //简介
    @Field(type = FieldType.Text, index = false)
    private String synopsis;
    @Field(type = FieldType.Text, index = false)
    private String remark;
    //商品图片集合
    @Field(type = FieldType.Nested)
    private List<String> urls;
    //商品品牌信息
    @Field(type = FieldType.Object)
    private ESNamed brand;
    //商品分类集合
    @Field(type = FieldType.Nested)
    private List<GoodsCategory> categorys;
    //商品活动集合
    @Field(type = FieldType.Nested)
    private List<GoodsActivity> activitys;
    @Field(type = FieldType.Long)
    private Long shopId;
    @Field(type = FieldType.Keyword, store = true)
    private String shopName;
    @Field(type = FieldType.Long)
    private Long areaId;
    @Field(type = FieldType.Text)
    private String areaName;
    @Field(type = FieldType.Keyword, store = true)
    private String areaCode;
    //经纬度
//    @GeoPointField
//    private String  location;
}
